<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateLessonDiscussionTable extends Migration {

	/**
	 * Run the migrations.
     *
     * 用于创建课程相关的讨论
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('lesson_discussions', function(Blueprint $table){
            $table->increments('id')->comment('主键id');
            $table->string('title', 40)->comment('讨论的标题');
            $table->text('content')->comment('讨论的主题');

            $table->unsignedInteger('lesson_id')->comment('对应的课程id');
            $table->foreign('lesson_id')->references('id')->on('lessons')->onDelete('cascade');

            $table->unsignedInteger('creater_id')->comment('对应的创建者id');
            $table->foreign('creater_id')->references('id')->on('users')->onDelete('cascade');

            $table->timestamps();
        });
	}

	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('lesson_discussions');
	}

}
